/**
* 
*	公共类
*	作者：邓磊
*	时间：2016年7月4日 16:40:43
*	作用：提供公共方法
*	继承对象：无
*
*/
package com.eptok.weixin.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;


public class BaseDispatchAction{

	private static final Logger LOG = Logger.getLogger(BaseDispatchAction.class);
	protected static final String PATH = "/pages/wx";
	
	
	public ModelAndView toSuccess(HttpServletRequest request,String code,String msg)
	{
		request.setAttribute("msg", msg);
		request.setAttribute("code", msg);
		return new ModelAndView("/pages/wx/success");
	}
	
	public ModelAndView toFail(HttpServletRequest request,String code,String msg)
	{
		request.setAttribute("msg", msg);
		request.setAttribute("code", code);
		return new ModelAndView("/pages/wx/error");
	}
	
	public String toRedirect(String url)
	{
		return "redirect:"+url;
	}
	
	public String getBaseUrl(HttpServletRequest request)
	{
		return "http://"+request.getServerName()+request.getContextPath();
	}
	
}
